﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brain;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Demos
{
    public class DescriptionScreen : GameScreen
    {
        public Sprite Description;
        public Sprite Title;
        public Sprite Background;
        public GameScreen GameScreen;

        public DescriptionScreen(string title, string description, GameScreen gs)
        {
            this.GameScreen = gs;

            Viewport Viewport = Engine.Instance.GraphicsDevice.Viewport;

            SpriteFont Font24 = Engine.Instance.ContentManager.Load<SpriteFont>(@"Game\\Fonts\\Segoe24");
            SpriteFont Font32 = Engine.Instance.ContentManager.Load<SpriteFont>(@"Game\\Fonts\\Segoe32");

            Background = new Sprite();
            Background.BoundsRectangle = new Rectangle(10, 10, Viewport.Width - 20, Viewport.Height - 20);
            Background.BoundsRectangleColor = new Color(120, 120, 120, 220);
            Background.Rendering = SpriteRendering.Rendered;

            Description = new Sprite();
            Description.SpriteFont = Font24;
            Description.Text = description;
            Description.UpdateBoundsRectangle();
            Description.BoundsRectangle = RectangleUtil.CenterRectangle(Description.BoundsRectangle, Viewport.Width, 100);
            Description.BoundsRectangle = new Rectangle(Description.BoundsRectangle.X,
                100, Description.BoundsRectangle.Width, Description.BoundsRectangle.Height);
            Description.Shadow = 2;
            Description.Rendering = SpriteRendering.Rendered;

            Title = new Sprite();
            Title.Color = Color.White;
            Title.SpriteFont = Font32;
            Title.Text = title;
            Title.UpdateBoundsRectangle();
            Title.BoundsRectangle = RectangleUtil.CenterRectangle(Title.BoundsRectangle, Viewport.Width, 100);
            Title.Shadow = 2;
            Title.Rendering = SpriteRendering.Rendered;
        }

        public override void Update()
        {
            base.Update();

            if (Engine.Instance.InputManager.IsKeyPress(Keys.Enter))
            {
                Engine.Instance.ScreenManager.RemoveScreen(this);
                GameScreen.ShouldUpdate = true;
                GameScreen.ShouldDraw = true;

                Title.Dispose();
                Background.Dispose();
                Description.Dispose();
            }
        }
    }
}
